param(
    [string]$location = "d:\log\",
    [string]$logFileLocation = "d:\log\log\log.txt",
    [bool]$logEnabled = $true
)

if ($logEnabled) {
    $allResult=@()
    for ($i = 0; $i -lt 100; $i++) {
        $fileName=$location+"file"+$i+".txt"
        New-Item -Path $fileName -ItemType File -Force

        if($?){
            $result+="$fileName created successfully"
            $allResult=$allResult+$result
        }
    }

    $allResult | Out-File -FilePath $logFileLocation -Append -Encoding utf8
} else {
    for ($i = 0; $i -lt 100; $i++) {
        $fileName=$location+"file"+$i+".txt"
        New-Item -Path $fileName -ItemType File -Force
    }
}